package com.yuelan.codelib.utils;

import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;

public class VersionUtil {

	/**
	 * Role:取得程序的当前版本<BR>
	 * Date:2012-4-5<BR>
	 * 
	 * @author ZHENSHI)peijiangping
	 */
	public static String getVerName(Context context) {
		String verName = null;
		try {
			verName = context.getPackageManager().getPackageInfo(
					context.getPackageName(), 0).versionName;
		} catch (NameNotFoundException e) {
			e.printStackTrace();
		}
		return verName;
	}
	
	/**
	 * Role:取得程序的当前版本<BR>
	 * Date:2012-4-5<BR>
	 * 
	 * @author ZHENSHI)peijiangping
	 */
	public static String getVerCode(Context context) {
		String verName = null;
		try {
			verName = context.getPackageManager().getPackageInfo(
					context.getPackageName(), 0).versionName;
		} catch (NameNotFoundException e) {
			e.printStackTrace();
		}
		return verName;
	}

	/**
	 * Role:是否更新版本<BR>
	 * Date:2012-4-5<BR>
	 * 
	 * @author ZHENSHI)peijiangping
	 */
	public boolean yesOrNoUpdataApk(String nowVersion, String newVersion) {
		if (Double.valueOf(newVersion) > Double.valueOf(nowVersion)) {
			// doNewVersionUpdate(nowVersion, newVersion);
			return true;
		}
		return false;
	}
}
